import 'package:flutter/material.dart';
import 'package:flutter_app_demo/base/widget/common_app_bar.dart';
import 'package:flutter_app_demo/pages/home/tab_one_page_view_model.dart';
import 'package:mvvm_plus/mvvm_plus.dart';

// Created by 王亮 on 2025/2/10.
class TabOnePage extends ViewWidget<TabOnePageViewModel> {
  TabOnePage({super.key}) : super(builder: () => TabOnePageViewModel());

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: CommonAppBar(
        showLeading: false,
        title: '首页',
      ),
      body: Center(
        // Center is a layout widget. It takes a single child and positions it
        // in the middle of the parent.
        child: Column(
          // Column is also a layout widget. It takes a list of children and
          // arranges them vertically. By default, it sizes itself to fit its
          // children horizontally, and tries to be as tall as its parent.
          //
          // Invoke "debug painting" (press "p" in the console, choose the
          // "Toggle Debug Paint" action from the Flutter Inspector in Android
          // Studio, or the "Toggle Debug Paint" command in Visual Studio Code)
          // to see the wireframe for each widget.
          //
          // Column has various properties to control how it sizes itself and
          // how it positions its children. Here we use mainAxisAlignment to
          // center the children vertically; the main axis here is the vertical
          // axis because Columns are vertical (the cross axis would be
          // horizontal).
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            const Text(
              'You have pushed the button this many times:',
            ),
            Text(
              '${viewModel.counter}',
              style: Theme.of(context).textTheme.headlineMedium,
            ),
            TextButton(onPressed: () => viewModel.launchLiveMainPage(), child: const Text("直播模块")),
            TextButton(
              onPressed: () {
                viewModel.initRuixueSdk();
              },
              child: const Text("初始化瑞雪 SDK"),
            ),
            Text(
              viewModel.initRuixueResult,
              style: Theme.of(context).textTheme.bodySmall,
            ),
            TextButton(
              onPressed: () {
                viewModel.launchOnePage();
              },
              child: const Text("跳转到 OnePage"),
            )
          ],
        ),
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: () {
          viewModel.incrementCounter();
        },
        tooltip: 'Increment',
        child: const Icon(Icons.add),
      ), // This trailing comma makes auto-formatting nicer for build methods.
    );
  }
}
